package javabase.schoolwork.day6_07;

/**
 * @author fance
 * @date 2018/6/7 20:37
 */
class ThreadA extends Thread {
    private long sleep;

    public ThreadA(long sleep) {
        this.sleep = sleep;
    }

    @Override
    public void run() {
        try {  System.out.println(Thread.currentThread().getName() + "休眠开始");
            Thread.sleep(sleep);
            System.out.println(Thread.currentThread().getName() + "休眠结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}class ThreadB extends Thread {
    private long sleep;

    public ThreadB(long sleep) {
        this.sleep = sleep;
    }
    @Override
    public void run() {
        try {  System.out.println(Thread.currentThread().getName() + "休眠开始");
            Thread.sleep(sleep);
            System.out.println(Thread.currentThread().getName() + "休眠结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}class ThreadC extends Thread {
    private long sleep;

    public ThreadC(long sleep) {
        this.sleep = sleep;
    }
    @Override
    public void run() {
        try {
            System.out.println(Thread.currentThread().getName() + "休眠开始");
            Thread.sleep(sleep);
            System.out.println(Thread.currentThread().getName() + "休眠结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
public class ThreeThread {
    public static void main(String[] args) {
        ThreadA threadA = new ThreadA(1000);
        threadA.setName("A");
        ThreadB threadB = new ThreadB(2000);
        threadB.setName("B");
        ThreadC threadC = new ThreadC(3000);
        threadC.setName("C");

        threadA.start();
        threadB.start();
        threadC.start();
    }
}
